<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="团长名称">
              <a-input placeholder="请输入团长名称" v-model="queryParam.shopName"></a-input>
<!--              <j-input v-model="queryParam.shopName" placeholder="请输入团长名称"></j-input>-->
            </a-form-item>
          </a-col>
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="团长电话">
              <a-input placeholder="请输入团长电话" v-model="queryParam.tel"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-item label="地址">
              <a-input placeholder="请输入地址" v-model="queryParam.location"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="4" :lg="7" :md="8" :sm="24">
            <a-form-item label="状态">
<!--              <j-dict-select-tag  dictCode="shop_status" v-model="queryParam.status"></j-dict-select-tag>-->
              <a-select  v-model="queryParam.status" placeholder="请选择状态">
                <a-select-option value="">
                  全部
                </a-select-option>
                <a-select-option value="1">
                  已上线
                </a-select-option>
                <a-select-option value="3">
                  已下线
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="4" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
<!--              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>-->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
<!--    <div class="table-operator">-->
<!--      <a-button @click="handleAdd" type="primary" icon="plus">新增团长</a-button>-->
<!--      <a-button type="primary" icon="download" @click="handleExportXls('路线模块')">导出</a-button>-->
<!--      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>-->
<!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
<!--        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>-->
<!--        <a-button style="margin-left: 8px" @click="batchDel1"> 批量取消下挂 <a-icon type="down" /></a-button>-->
<!--      </a-dropdown>-->
<!--    </div>-->

    <!-- table区域-begin -->
    <div>
<!--      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>-->

<!--      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"-->
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"

        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="status_dictText" slot-scope="text,record">
          <div v-html="text" v-if="record.status==1" style="color: #4D90FE;"></div>
          <div v-html="text" v-else style="color: #ff5500"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>
        <span slot="action" slot-scope="text, record">
          <span>
            <a @click="handleXiaGua(record.id)">下挂</a>
<!--            <a-popconfirm title="确定下挂吗?" @confirm="() => handleXiaGua(record.id)">

            </a-popconfirm>-->
          </span>
        </span>

      </a-table>
    </div>

<!--    <TuanZhangModal ref="tuanzhangmodal" @ok="modalFormOk"></TuanZhangModal>-->
<!--    <SeeRouteModal ref="seeModalForm" @ok="modalFormOk"></SeeRouteModal>-->
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin1'
  import Edittablecell from './Edittablecell.vue'
  import TuanZhangModal from './TuanZhangModal'
  import { deleteAction, putAction ,postAction} from '@api/manage'
  import JDictSelectTag from "@/components/dict/JDictSelectTag"
  import JInput from '@/components/jeecg/JInput'

  export default {
    name: 'TuanZhangForm',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      Edittablecell,
      JDictSelectTag,
      JInput,
      TuanZhangModal
    },
    data () {
      return {
        update:true,
        id:'',
        xianlu:'',
        description: '线路下团长查看',
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'团长名称',
            align:"center",
            dataIndex: 'shopName'
          },
          {
            title:'团长电话',
            align:"center",
            dataIndex: 'tel'
          },
          {
            title:'地址',
            align:"center",
            dataIndex: 'location'
          },
          {
            title:'详细地址',
            align:"center",
            dataIndex: 'address'
          },
          {
            title:'状态',
            align:"center",
            dataIndex: 'status_dictText',
            scopedSlots: { customRender: 'status_dictText' }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            // fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          // list: "/shop/route/list",
          list:"/shopInfo/shopInfo/routeShopList",
          delete: "/shop/route/delete",
          exportXlsUrl: "/shop/route/exportXls",
          importExcelUrl: "shop/route/importExcel",
          add:"/shop/routeShop/add" //下挂团长
        },
        dictOptions:{},
      }
    },
    created() {
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      add(xianlu,id){
        this.xianlu = xianlu
        this.id = id
        /*this.queryParam.routeId = record.id
        this.routeId = record.id*/
        this.loadData()
      },
      searchReset(){
        this.update = false
        console.log(this.routeId)
        this.queryParam = {}
        this.queryParam.routeId = this.routeId

        this.loadData(1);
        this.$nextTick(() => {
          this.update = true
        })
      },
      //下挂
      handleXiaGua(id){
        console.log('团长ID：'+id)
        console.log('线路ID：'+this.id)
        this.loading = true
        postAction(this.url.add,{shopInfoId:id, routeId:this.id}).then((res)=>{
          if (res.success) {
            this.$message.success(res.message);
            this.loadData();
          } else {
            this.$message.warning(res.message);
          }
        }).finally(() => {
          this.loading = false;
        });
      }

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>